import { defineStore } from 'pinia'

import { pagesMap } from '@/utils/router/routes'

export const useRouterStore = defineStore({
  id: 'routerStore',
  state: () => ({
    routes: undefined,
    currentRouter: undefined
  }),
  getters: {
    getRoutes (state) {
      return state.routes
    },
    getCurrentRoute (state) {
      return state.currentRouter
    }
  },
  actions: {
    initialize () {
      this.setRoutes()
    },
    setRoutes () {
      this.routes = pagesMap
    },
    setCurrentRoute (path) {
      this.currentRouter = this.routes?.get(path) || undefined
    }
  }
})
